home *** CD-ROM | disk | FTP | other *** search
/ HAM Radio 1997 / HAM Radio 1997.iso / vcls / formset / formset.doc < prev    next >
Text File  |  1996-04-08  |  5KB  |  132 lines

  1.  
  2. A FormSet is a custom control based on the Delphi TabSet. You can
  3. install it on the tool palette through Options/Install Components on
  4. the Delphi action bar menu. I haven't learned how to write Windows
  5. help yet, so this file is all there is.
  6.  
  7. FormSet is derived from TabSet. All the properties, methods and events
  8. that are documented for TabSets also work with FormSets. With a TabSet
  9. you probably map each tab to a page in a NoteBook. With a FormSet you
  10. map each tab to a form. We'll call the form that has the FormSet the
  11. Parent or Book form, and the forms displayed with the tabs Child or
  12. Page forms. When you click on a tab, the FormSet displays the Child
  13. form in the client area of the Parent. When you change tabs, the
  14. FormSet can release the old form for best memory use, or leave it in
  15. memory for best performance.
  16.  
  17. Child or Page forms are as normal as I could make them. Be sure to
  18. define them with Visible as False and BorderStyle anything but bsNone.
  19. If you want dynamically created forms, move them from the AutoCreate
  20. list to the Availble list.
  21.  
  22. In the designer, you build a FormSet just like a TabSet. You may
  23. specify the tab captions in the Tabs array or add them at runtime
  24. through FormSet.Tabs.Add('Caption').
  25.  
  26. There is one additional event which you MUST handle. It is called
  27. OnTabLoad. The FormSet calls this event any time a tab is clicked and
  28. the FormSet does not have the Child TForm.
  29.  
  30. The first parameter for OnTabLoad is the usual Delphi Sender. The
  31. second is the TabIndex of the tab which is being loaded. The third
  32. parameter is an object called TFormTab, defined as follows:
  33.  
  34.    TFormTab = class
  35.       Form      : TForm;
  36.       OnOpen    : TFTOpen;
  37.       OnClose   : TFTClose;
  38.       Height    : Integer;
  39.       Width     : Integer;
  40.    end;
  41.  
  42. You must fill the Form property, probably like this:
  43.  
  44.    select case TabIndex
  45.       case 0 : TFormTab.Form := TPage1.Create(Self);
  46.       case 1 : TFormTab.Form := TPage2.Create(Self);
  47.       case 2 : TFormTab.Form := TPage3.Create(Self);
  48.    end;
  49.  
  50.    or if you prefer a caption to an index:
  51.  
  52.    Caption := FormSet1.Tabs[TabIndex]
  53.    if Caption = 'Home' then FormTab.Form := TPage1.Create(Self);
  54.    if Caption = 'Auto' then FormTab.Form := TPage2.Create(Self);
  55.    if Caption = 'Life' then FormTab.Form := TPage3.Create(Self);
  56.  
  57. OnOpen can have one of the following values:
  58.  
  59.    ftoSizePageToBook  - Size the Child to match the Parent.  This
  60.                         makes all Child forms the same size for a
  61.                         smooth appearance.  This version uses the
  62.                         original size of the Parent. If the user
  63.                         resizes it, FormSet will restore it to the
  64.                         original size.  This may not be good!
  65.    ftoSizeBookToPage  - Size the Parent to match the Child.  This
  66.                         could be used to accomodate one large Child
  67.                         without enlarging the Parent all the time.
  68.                         Not yet implemented correctly.
  69.  
  70. OnClose can have one of the following values:
  71.  
  72.    ftcAlwaysRelease   - Release the form when changing to another tab
  73.    ftcNeverRelease    - Do not release the form
  74.    ftcMaybeRelease    - Release the form later if memory runs low
  75.                         Not yet implemented.
  76.  
  77. FormSet copys the Height and Width from the child form into the Height
  78. and Width properties the first time through.  If your program loads
  79. them with non-zero values, FormSet will use those values.
  80.  
  81. If you feel the urge to access FormTab objects directly, you can do so
  82. in any part of your code:
  83.  
  84.    var
  85.       FormTab : TFormTab;
  86.    begin
  87.       FormTab := FormSet1.Tabs.Objects[TabIndex];
  88.       FormTab.Property := Value;
  89.  
  90.  
  91. With a Delphi TabSet, events are triggered in this order:
  92.  
  93.    TabSet.Change
  94.    TabSet.Click
  95.  
  96. If the user clicks on a tab which is already active, neither event is
  97. fired.  If the code in onChange sets the AllowChange parameter to
  98. False, the change does not happen and onClick is not fired.
  99.  
  100. With FormSet, events are triggered as shown below. This sequence may
  101. seem odd until you realize the stages it goes through. First, FormSet
  102. checks to make sure the change is ok with all parties involved:
  103.  
  104.    OldPage.CloseQuery - The old form can abort the change by setting
  105.    CanClose to False; none of the other events in the list fire. It
  106.    might do this if it has some unfinished business on screen.
  107.  
  108.    NewPage.Create - Done only if the new form has not already been
  109.    created. If FormSet.OnTabLoad does not create the new form, FormSet
  110.    aborts the change and none of the other events fire.
  111.  
  112.    FormSet.Change - The application can abort the change here by
  113.    setting AllowChange to False. None of the other events fire.
  114.  
  115. Next we close one form and open another:
  116.  
  117.    OldPage.Hide - Always happens.  Gives the old page a chance to save
  118.    data.
  119.  
  120.    OldPage.Destroy - happens only if the old page has OnClose property
  121.    set to fscAlwaysRelease.
  122.  
  123.    NewPage.Show - Always happens.  Gives the new page a chance to load
  124.    data.
  125.  
  126. Finally, like the original TabSet control, FormSet fires the Click
  127. event after all the interesting stuff has already happened. The new
  128. page is already visible by this time.
  129.  
  130.    FormSet.Click
  131.  
  132.